define(function(require) {
	var $ = require("jquery");
	var justep = require("$UI/system/lib/justep");
	var comUtil = require("$UI/system/components/justep/common/common");

	var Model = function() {
		this.callParent();
	};

	//获取轮换图片
	Model.prototype.imgDataCustomRefresh = function(event) {
		var imgData = event.source;
		$.ajax({
			type : "GET",
			url : require.toUrl('./index/json/imgData.json'),
			dataType : 'json',
			async : false,//使用同步方式，目前data组件有同步依赖
			cache : false,
			success : function(data) {
				imgData.loadData(data);//将返回的数据加载到data组件
			},
			error : function() {
				throw justep.Error.create("加载数据失败");
			}
		});
		var url = new Array();
		imgData.each(function(obj) {
			url.push(require.toUrl(obj.row.val("fImgUrl")));
		});
		$("#image1").attr({
			"src" : url[0]
		});
		$("#image2").attr({
			"src" : url[1]
		});
	};
	Model.prototype.menuDataCustomRefresh = function(event) {
		var menuData = event.source;
		$.ajax({
			type : "GET",
			url : require.toUrl('./index/json/menuData.json'),
			dataType : 'json',
			async : false,//使用同步方式，目前data组件有同步依赖
			cache : false,
			success : function(data) {
				menuData.loadData(data);//将返回的数据加载到data组件
			},
			error : function() {
				throw justep.Error.create("加载数据失败");
			}
		});
	};
	Model.prototype.dataCustomRefresh = function(event) {
		var navData = event.source;
		$.ajax({
			type : "GET",
			url : require.toUrl('./index/json/data.json'),
			dataType : 'json',
			async : false,//使用同步方式，目前data组件有同步依赖
			cache : false,
			success : function(data) {
				navData.loadData(data);//将返回的数据加载到data组件
			},
			error : function() {
				throw justep.Error.create("加载数据失败");
			}
		});
	};

	//搜索按钮
	Model.prototype.seachBtnClick = function(event) {
		/*
		 1、获取搜索框中的值
		 2、传入弹出窗口，弹出窗口中显示列表页
		 3、在弹出窗口的接收事件中，从服务端过滤数据
		 */
	};

	//
	Model.prototype.menuColClick = function(event) {
		/*
		 加入链接，打开相应页面
		 */
	};

	//微淘按钮
	//	Model.prototype.microBtnClick = function(event){
	////		this.loadContainer("mineContainer", "$UI/communityOto/home/categoryFragment.w");
	//	};
	
	//	Model.prototype.myCommunityClick = function(event){
	//		this.loadContainer("communityContainer", "$UI/communityOto/home/communityActivity.w");
	//	};

	//分类信息按钮
	//	Model.prototype.foundBtnClick = function(event){
	//		this.loadContainer("categoryContainer", "$UI/communityOto/home/categoryFragment.w");
	//		this.comp("titleBar1").set({title:"分类信息"});
	//	};

	//我的按钮
	//	Model.prototype.userBtnClick = function(event){
	//		this.loadContainer("mineContainer", "$UI/communityOto/home/mineFragment.w");
	//		this.comp("titleBar1").set({title:"我的"});
	//	};

	//图片路径转换
	Model.prototype.getImageUrl = function(url) {
		return require.toUrl(url);
	};

	Model.prototype.loadContainer = function(container, url) {
		var container = this.comp(container);
		var src = container.get("src");
		if (src != url) {
			container.set({
				"src" : url
			});
			container.refresh();
		}
	};
	//	Model.prototype.myCommunityClick = function(event){
	//		this.loadContainer("mineContainer", "$UI/communityOto/home/mineFragment.w");
	//	};

	Model.prototype.shopsBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	Model.prototype.sqBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shequgonggao.w");
	};

	Model.prototype.wybtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/wuyetongzhi.w");
	};

	Model.prototype.yeBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	Model.prototype.bmBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	Model.prototype.ppBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	Model.prototype.jkClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	Model.prototype.wcBtnClick = function(event) {
		justep.Shell.showPage("$UI/communityOto/home/shopListActivity.w");
	};

	

	


	

	

	

	

	


	

	

	Model.prototype.microBtnClick = function(event){
	   if(!localStorage.getItem("userInfo")){
		   this.comp("communityContainer").setSrc("$UI/communityOto/mine/login.w");
	       this.comp("communityContainer").refresh();
	   }
	};

	Model.prototype.userBtnClick = function(event){
		this.comp("mineContainer").setSrc("$UI/communityOto/mine/mineFragment.w");
		this.comp("mineContainer").refresh();
	};

	
	

	


	

	

	

	

	


	

	

	return Model;
});